package com.kws.system.api.factory;

import com.kws.common.core.domain.R;
import com.kws.system.api.RemoteToolService;
import com.kws.system.api.domain.*;
import com.kws.system.api.domain.Rq.QueryExpress100Rq;
import com.kws.system.api.domain.Rq.UserDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author : zhangbenting
 * @date : 2024/11/25 16:14
 * @Version: 1.0
 */
@Component
public class RemoteToolFallbackFactory implements FallbackFactory<RemoteToolService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteToolFallbackFactory.class);

    @Override
    public RemoteToolService create(Throwable throwable) {
        log.error("工具服务调用失败:{}", throwable.getMessage());
        return new RemoteToolService() {

            @Override
            public R<ResultDto> eVerify(UserDto userDto) {
                return R.fail("实名认证:" + throwable.getMessage());
            }

            @Override
            public R<Express100Info> queryExpressDeliveryPage(QueryExpress100Rq rq) {
                return R.fail("查询物流消息:" + throwable.getMessage());
            }

            @Override
            public R<PhotovoltaicVo> photovoltaicCalculation(PhotovoltaicDto photovoltaicDto) {
                return R.fail("光伏测算:" + throwable.getMessage());
            }

            @Override
            public R<EQBTemplateVo> saveContract(MultipartFile file) {
                return R.fail("合同模板上传:" + throwable.getMessage());
            }

            @Override
            public R deleteContract(String id) {
                return R.fail("删除模板:" + throwable.getMessage());
            }

            @Override
            public R<ResultDto> getComponentsInfo(String docTemplateId) {
                return R.fail("查询模板控件出错:" + throwable.getMessage());
            }

            @Override
            public R<ResultDto> createByDocTemplate(CreateTemplate createTemplate) {
                return R.fail("填充模板出错:" + throwable.getMessage());
            }

            @Override
            public R<ResultDto> createContract(CreateContractDto createContractPo) {
                return R.fail("创建合同并发起:" + throwable.getMessage());
            }

            @Override
            public R<ResultDto> signViewLink(String signFlowId) {
                return R.fail("查看合同:" + throwable.getMessage());
            }

            @Override
            public R<ResultDto> signLink(QuerySignUrlRq querySignUrlRq) {
                return R.fail("获取签署链接:" + throwable.getMessage());
            }

            @Override
            public R<ResultDto> fileDownloadUrl(String signFlowId) {
                return R.fail("获取文件下载地址:" + throwable.getMessage());
            }

            @Override
            public R<ResultDto> signFlowDetail(String signFlowId) {
                return R.fail("获取签署流程详情:" + throwable.getMessage());
            }

            @Override
            public R<ResultDto> signFlowList(SignFlowRq signFlowRq) {
                return R.fail("获取文件签署列表:" + throwable.getMessage());
            }

            @Override
            public R<ResultDto> signFlowRevoke(SignFlowRevoke signFlowRevoke) {
                return R.fail("撤销签署流程:" + throwable.getMessage());
            }
        };
    }
}
